//
//  VDMessageViewController.m
//  Runone
//
//  Created by runone01 on 16/10/24.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "VDMessageViewController.h"
#import "VDMessageCell.h"
#import "DMVDCurrentDataInfo.h"
#import "MJExtension.h"

@interface VDMessageViewController ()
@property(nonatomic,strong)DMVDCurrentDataInfo *model;
@property(nonatomic,strong)NSMutableArray *arr;
@end

@implementation VDMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _arr=[[NSMutableArray alloc] init];
    self.preferredContentSize=CGSizeMake(self.view.frame.size.width-60, 480);
    [self.tableView registerNib:[UINib nibWithNibName:@"VDMessageCell" bundle:nil] forCellReuseIdentifier:@"VDMessageCell"];
    self.tableView.bounces                      = NO;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    
    for (NSDictionary *dic in _dataSource)
        {
            DMVDCurrentDataInfo *model=[DMVDCurrentDataInfo mj_objectWithKeyValues:dic];
            [_arr addObject:model];
        }

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _arr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    VDMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VDMessageCell" forIndexPath:indexPath];
    _model=_arr[indexPath.row];
    cell.chedao.text=_model.LANE_NO;
    cell.liangzhi.text=_model.VOLUME;
    cell.suduzhi.text=_model.SPEED;
    cell.zhanyoulv.text=_model.OCCUPANCY;
    cell.updateTime.text=_model.LAST_UPDATE;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
